package model;

import java.io.Serializable;
import java.util.Date;

public abstract class User implements Serializable {
    private static final long serialVersionUID = 1L;
    protected String userId;
    protected String username;
    protected String password;
    protected String userType;
    protected String phone;
    protected Date registerTime;

    public User(String userId, String username, String password, String userType, String phone, Date registerTime) {
        this.userId = userId;
        this.username = username;
        this.password = password;
        this.userType = userType;
        this.phone = phone;
        this.registerTime = registerTime;
    }

    // 登录验证
    public boolean login(String inputPassword) {
        return this.password.equals(inputPassword);
    }

    // 修改自身密码
    public boolean changePassword(String oldPassword, String newPassword) {
        if (!this.password.equals(oldPassword)) {
            return false;
        }
        this.password = newPassword;
        return true;
    }

    // 抽象方法：显示菜单
    public abstract void showMenu();

    // Getter和Setter
    public String getUserId() { return userId; }
    public String getUsername() { return username; }
    public String getPassword() { return password; }
    public void setPassword(String password) { this.password = password; }
    public String getUserType() { return userType; }
    public void setUserType(String userType) { this.userType = userType; }
    public String getPhone() { return phone; }
    public void setPhone(String phone) { this.phone = phone; }
    public Date getRegisterTime() { return registerTime; }
}
